var catregory = 0;
var pageNumber = 1;
$(function() {
	labelGet(0);
	labelGet(1);
	labelGet(2);
	labelGet(3);
});

/**
 * 论文
 */
function labelGet(type) {
	$("#labelType").val(type);
	var content = "";
	$
			.post(
					"getLableList",
					$("#labelGetForm").serialize(),
					function(responseResult) {
						console.log(responseResult.labelList);
						var list = responseResult.labelList;
						if (responseResult.labelList.length > 0) {
							var count = responseResult.labelList.length;
							for (var i = 0; i < count / 5; i++) {
								content += "<tr>";
								for (var j = 5 * i; j < 5 * (i + 1); j++) {
									if (j < count) {
										content += "<td><div class='checkbox'>"
												+ "<span class='guoxuan' style='font-size:20px' style=''>"
												+ list[j].lable
												+ "</span><input type='checkbox' id='"
												+ list[j].id
												+ "'  name='' style='display:none;'>"
												+ "<label for='" + list[j].id
												+ "' >√</label></div></td>";
									} else {
										content += "<td>&nbsp;</td>";
									}
								}
								content += "</tr>";
							}
							$('#label' + type).append(content);
						} else {
							$('#label' + type).apend("无相关数据！");
						}
					});
}

function addLabel() {
	var label = $("#labelInput").val().trim();
	if (label == "") {
		alert("请输入标签名。");
		return;
	}
	$.post("addLable", $("#labelAddForm").serialize(),
			function(responseResult) {
				alert(responseResult.responseParam.message);
				location.reload();
			});
}

/**
 * 获取多选框的id组合
 * 
 * @returns {String}
 */
function valueGetFromCheckbox() {
	var input = document.getElementsByTagName("input");
	var inputCount = input.length;
	var values = "";
	for (var i = 0; i < inputCount; i++) {
		if (input[i].type == "checkbox" && input[i].checked) {
			if (values == "") {
				values += input[i].id;
			} else
				values += "," + input[i].id;
		}
	}
	return values;
}

/*
 * function labelDelete(){ var value = valueGetFromCheckbox(); if(value = ""){
 * alet("请选择标签。"); return; } if(confirm("确认删除这些标签吗？")){
 * $.post("addLable",$("#labelGetForm").serialize(),function(responseResult){
 * alert(responseResult.responseParam.message); }); } }
 */